package com.jian.java.controller;

import com.jian.java.bean.Student;
import com.jian.java.mapper.StudentsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author Jiange
 * @create 2021-04-29-20:19
 */
@Controller
public class Mycontroller {
    @Autowired
    JdbcTemplate jdbcTemplate;

    @Autowired
    StudentsMapper studentsMapper;

    @ResponseBody
    @GetMapping("/query")
    public String test1(){
        Long aLong = jdbcTemplate.queryForObject("select count(*) from students", Long.class);
        System.out.println("aLong = " + aLong);
        return "druid";
    }

    @ResponseBody
    @GetMapping("/queryall")
    public String test2(){
        List<Student> students = studentsMapper.queryAll();
        students.forEach(System.out::println);
        return  "";
    }
}
